package chapter06

object Test11_Object {
  def main(args: Array[String]): Unit = {
    val student = new Student11("alice", 18)
    student.printInfo()
    val student1 = Student11.newStudent11("bob", 19)
    student1.printInfo()
    val student2 = Student11.apply("bob", 19)
    student2.printInfo()
    val student3 = Student11("bob", 19)
    student3.printInfo()
  }
}

class Student11(val name: String, val age: Int) {
  def printInfo() = {
    println(s"student: name=$name,age=$age,school=${Student11.school}")
  }
}

object Student11 {
  var school: String = "school"

  def newStudent11(name: String, age: Int): Student11 = new Student11(name, age)

  def apply(name: String, age: Int): Student11 = new Student11(name, age)
}
